<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>演示列表渲染</title>
    <script src="./js/vue@3.5.12.global.js"></script>
</head>
<style>
    td{
        text-align: center;
    }
</style>
<body>
    <div id="app">
        <table width="100%" border="1">
            <tr>
                <th>编号</th>
                <th>姓名</th>
                <th>性别</th>
                <th>联系方式</th>
            </tr>
            <tr v-for="emp in employees" :key="emp.id">
                <td>{{emp.id}}</td>
                <td>{{emp.name}}</td>
                <td>{{emp.gender}}</td>
                <td>{{emp.phone}}</td>
            </tr>
        </table>
        <hr>
        <table width="100%" border="1">
            <tr>
                <th>索引</th>
                <th>编号</th>
                <th>姓名</th>
                <th>性别</th>
                <th>联系方式</th>
            </tr>
            <tr v-for="(emp,index) in employees" :key="index">
                <td>{{index}}</td>
                <td>{{emp.id}}</td>
                <td>{{emp.name}}</td>
                <td>{{emp.gender}}</td>
                <td>{{emp.phone}}</td>
            </tr>
        </table>
    </div>
</body>
<script>
    const app = Vue.createApp({
        data(){
            return {
                //声明一个员工数组：json数组
                employees:[
                    {id: 1001,name:'jack',gender:'男',phone: '135421082033'}, //json对象
                    {id: 1002,name:'rose',gender:'女',phone: '135451082033'},
                    {id: 1003,name:'张三',gender:'男',phone: '135461082033'}
                ]
            }
        }
    })
    app.mount('#app');
</script>
</html>